<?php
namespace App\Repositories;

use App\Exceptions\BasicException;
use Illuminate\Support\Facades\Hash;
use function Matrix\add;    //引入hash

class GameEntranceRepository
{
    /**
     * 新增游戏
     * @param  $param
     * @return bool
     * @throws BasicException
     */
    public function  add($param){
        $add = app('model_game_entrance')->create($param);
        if ($add) return $add;
        throw new BasicException(93143);
    }
    /**
     * 游戏详情
     * @param  $id
     * @return bool
     * @throws BasicException
     */
    public  function  detail($id){
        $detail = app('model_game_entrance')->where('id',$id)->first();
        if ($detail) return $detail->toArray();
        throw new BasicException(93144);
    }
    /**
     * 编辑游戏
     * @param  $param
     * @return bool
     * @throws BasicException
     */
    public  function  save($param){
        $save = app('model_game_entrance')->where('id',$param['id'])->update($param);
        if ($save!==false) return true;
        throw new BasicException(93145);
    }

    /**
     * 删除游戏
     * @param  $id
     * @return bool
     * @throws BasicException
     */
    public  function  del($id){
        $del = app('model_game_entrance')->where('id',$id)->delete();
        if ($del) return $del;
        throw new BasicException(93146);
    }

    /**
     * 获取列表
     * @param  $id
     * @return bool
     * @throws BasicException
     */
    public  function  list(){
        $del = app('model_game_entrance')->get()->toArray();
        return $del;
    }

    /**
     * 获取列表
     * @param  $game_id
     * @return bool
     * @throws BasicException
     */
    public  function  limitGameId($game_id){
        $limitGameId = app('model_game_entrance')->where('game_id',$game_id)->first();
        if ($limitGameId)  throw new BasicException(50025);
    }

}


?>